<?php
class ContentTypeFieldValuesModel {
	public static function get ($config) {
		return SleekPHP::db()->get('content_type_field_values', $config);
	}

	public static function insert ($row) {
		return self::insertUpdate($row);
	}

	public static function update ($id, $row) {
		return self::insertUpdate($row, $id);
	}

	private static function insertUpdate ($row, $id = false) {
		$content_type_fields_id	= isset($row['content_type_fields_id']) ? $row['content_type_fields_id'] : 0;
		$contents_id			= isset($row['contents_id']) ? $row['contents_id'] : 0;
		$contents				= isset($row['content']) ? $row['content'] : '';

		$fields = array(
			'content_type_fields_id'	=> $content_type_fields_id, 
			'contents_id'				=> $contents_id, 
			'contents'					=> $contents
		);

		if ($id) {
			return SleekPHP::db()->update('content_type_field_values', $id, $fields);
		}
		else {
			return SleekPHP::db()->insert('content_type_field_values', $fields);
		}
	}

	public static function delete ($id) {
		return SleekPHP::db()->delete('content_type_field_values', $id);
	}
}
